var QQMapWX = require('../../apis/qqmap-wx-jssdk.js'); //引入下载的sdk 
var qqmapsdk;
Page({
  data: {
    latitude: 0, //地图初次加载时的纬度坐标
    longitude: 0, //地图初次加载时的经度坐标
    name: "" //选择的位置名称
  },
  onLoad: function () {
    // 实例化API核心类
    qqmapsdk = new QQMapWX({
      key: 'MLQBZ-E77W2-JTGU7-CVCYV-4JX4H-H2FNR'
    });

    this.moveToLocation();
  },
  //移动选点
  moveToLocation: function () {
    var that = this;
    // 打开地图选择位置
    wx.chooseLocation({
      success: function (res) {
        // res.name为地址名称  
        console.log(res.name)
        // //选择地点之后返回到原来页面
        let pages = getCurrentPages();
        let prevPage = pages[pages.length - 2]; //上一个页面
          prevPage.setData({
            address: res.name,
            m_latitude:that.data.latitude,
            m_longitude:that.data.longitude
          });
          wx.navigateBack({
            delta: 1
          })
        // wx.navigateTo({
        //   url: '../../pages/recruitment/recruitcoopera?address=' + res.name,
        // })
      },
      fail: function (err) {
        wx.navigateBack({
          delta: 1
        })
      }
    });
  }
});